<template>
  <div class="t-background-exchange" @click="handleClick">
    <i class="iconfont icon-xiangce"></i>
  </div>
</template>

<script>
  export default {
    name: 't-background-exchange',
    methods: {
      handleClick() {
        this.$http.request({
          url: 'api/pictures/actions/random-load',
          method: 'get',
        }).then((response) => {
          window.localStorage.setItem('default-background-url', response.data.url);
          document.getElementById('t-background').style.backgroundImage = `url(${response.data.url})`;
        });
      },
    },
  };
</script>